package com.mvvm.start.common.receiver

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent

/**
 * @author lmy
 * @功能: 开机广播自动启动app
 * @Creat 2021/6/30 5:31 下午
 * @Compony 465008238@qq.com
 */
class BootBroadcastReceiver : BroadcastReceiver() {
    val ACTION = "android.intent.action.BOOT_COMPLETED"
    override fun onReceive(context: Context?, intent: Intent?) {
        if (intent?.action.equals(ACTION)) {
            val msgIntent: Intent = context?.packageName?.let { context?.packageManager.getLaunchIntentForPackage(it) } as Intent //获取启动Activity
            context?.startActivity(msgIntent)
        }
    }
}